package com.own.demo.lwf.utils.ownUtils;/**
 * @author liwenfeng
 * @date 2022/8/14 0014
 * @apinote
 */

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ArrayUtils;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @version v1.0
 * @Description:
 * @Author Administrator
 * @Date 2022/8/14 0014 10:17
 * @copyright 李文峰
 */
public class BaseUtilsDemo {
    public static void main(String[] args) {
        String[] array1 = new String[]{"1","5","8","3","4"};
        String[] array2 = new String[]{"18","5","88","3","34"};
        List<String> list1 = Arrays.asList(array1);
        List<String> list2 = Arrays.asList(array2);
        Map<Object, Object> map = new HashMap<>();


    // MapUtils
        // isEmpty:判空不会报错！判空不会报错！判空不会报错！不同判断！
        if(MapUtils.isEmpty(map)) {
            System.out.println("map为空！");
        }


    // ArrayUtils
        if(ArrayUtils.isEmpty(args)){
            System.out.println("数组为空！");
        }
        // addAll:合并数组 ArrayUtils.toString:打印数组,arrary.toString只能打印出来地址值
        String[] array3 = ArrayUtils.addAll(array1, array2);
        System.out.println(ArrayUtils.toString(array3));
        // clone：克隆数组,并不会随原改变
        String[] array4 = ArrayUtils.clone(array1);
        System.out.println(ArrayUtils.toString(array4));
        array4[4] = "老六";
        array1[2] = "秀儿";
        System.out.println(ArrayUtils.toString(array4));
        // 翻转
        ArrayUtils.reverse(array4);
        System.out.println(ArrayUtils.toString(array4));


    // CollectionUtils:注意要导入这个包！注意要导入这个包！注意要导入这个包！
        if(!CollectionUtils.isEmpty(list1)){
            System.out.println("list为空！");
        }
        // union:并集
        System.out.println(CollectionUtils.union(list1,list2));
        // intersection:交集
        System.out.println(CollectionUtils.intersection(list1,list2));
    }
}
